package com.mo.demo.ehcache;

import org.ehcache.expiry.ExpiryPolicy;

import java.time.Duration;
import java.util.function.Supplier;

public class MyExpiryPolicy<K, V> implements ExpiryPolicy<K, V> {

    @Override
    public Duration getExpiryForCreation(K k, V v) {
        return Duration.ofSeconds(5);
    }

    @Override
    public Duration getExpiryForAccess(K k, Supplier<? extends V> supplier) {
        return Duration.ofSeconds(5);
    }

    @Override
    public Duration getExpiryForUpdate(K k, Supplier<? extends V> supplier, V v) {
        return null;
    }
}
